import React,{useState,useEffect} from 'react'
import { NavBar } from 'antd-mobile'
import {useSearchParams} from 'react-router-dom'
import { Sticky} from 'react-vant'
import ProCode from './ProCode';
import axios from 'axios'
export default function SpecialEvent() {
    let [url, setUrl] = useSearchParams()
    let cate = url.get('cate')
    let [pros, setPros] = useState([])
    let getPro = async () => {
        let result = await axios.get('http://localhost:3000/zhaojunjie/cate_pro?cate=' + cate)
        if (result.data.code === 200) {
            setPros(result.data.data)
        }
    }
    useEffect(() => {
        getPro()
    },[])
    const back = () => {
        window.history.back();
    }
  return (
      <div className='specialEvent'>
          <Sticky>
              <NavBar onBack={back} style={{ borderBottom: '1px solid gainsboro', padding: '5px 0', fontSize: '20px', fontWeight: '600', backgroundColor: 'white' }}>{cate}</NavBar>
          </Sticky>
          <img src='z1.png' alt=''></img>
          <div className='prols'>
            {
            pros.map(ele => (
                <ProCode data={ ele} key={ele._id} />
            ))
            }
          </div>
      </div>
  )
}
